package com.cike.ssm.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cike.ssm.mapper.BankLanguageMapper;
import com.cike.ssm.po.BankLanguage;
import com.cike.ssm.service.BankLanguageService;
import com.cike.ssm.utils.ExportEntity;

@Service
public class BankLanguageServiceImpl implements BankLanguageService {
	@Autowired
	private BankLanguageMapper bankLanguageMapper;

	@Override
	public BankLanguage getById(double id) {
		return bankLanguageMapper.selectByPrimaryKey(id);
	}

	/**
	 * 查出所有已翻译的key
	 */
	@Override
	public List<String> getAlreadyInternational() {
		return bankLanguageMapper.getAlreadyInternational();
	}

	/**
	 * 对比得出需要国际化的内容
	 */
	@Override
	public List<ExportEntity> compareInternational(List<ExportEntity> list) {
		//用来存储需要翻译的内容
		List<ExportEntity> exportPOs = new ArrayList<ExportEntity>();
		//得出已经翻译的内容
		List<String> languages = getAlreadyInternational();
		for (ExportEntity exportPO : list) {
			if(!languages.contains(exportPO.getCode())){
				exportPOs.add(exportPO);
			}
		}
		return exportPOs;
	}

}
